
<html>
<head>
    <meta charset="UTF-8">
    <title>Welcome!</title>
        
    <link rel="stylesheet" type="text/css" href="/css/24fb281.css">
    <link href="/Tpl/Home/access/css/drag.css" rel="stylesheet" type="text/css" />
    <link href="/Tpl/Home/card/recharge.css" rel="stylesheet" type="text/css" />
    
    <link rel="icon" type="image/x-icon" href="/favicon.ico">
    <link href="__PUBLIC__/v2.3/lib/layer/2.1/skin/layer.css" rel="stylesheet" type="text/css" />
    <link href="__PUBLIC__/v2.3/lib/Validform/5.3.2/style.css" rel="stylesheet" type="text/css" />

    <style>
        #recharge{padding: 20px!important}
        .pd-r{padding-right: 0;margin-left: 50px;}
    </style>
</head>
<body>
<!-- <div class="formTitle">
    <span>列表设置</span>
</div> -->
<form action="" method="post" id="fields">
	<!-- <div class="form-group">
		<div for="" class="col-xs-3 col-offset-3 pd-r">类别</div>
		<div class="col-xs-6">排序</div>
	</div>
	<div class="form-group">
		<div for="" class="col-xs-3 col-offset-3 pd-r">
			<input type="checkbox" id="all" class="all" name="">  全选
		</div>
		<div class="col-xs-6"></div>
	</div>
	<volist name="data" id="v">

	<div class="form-group col_check">
        <div for="" class="col-xs-3 col-offset-3 pd-r box_col">
        	<input name="fields[]" type="checkbox" {:is_numeric($cookData[$v]) ?'checked':''} class="" value="{$v}">  {$key}
        </div>
        <div class="col-xs-6">
            <input name="{$v}" type="text" class="form-control" value="{$cookData[$v]?$cookData[$v]:0}">

        </div>
    </div>
    </volist> -->
    <div class="list_box">
        <div class="left">
          <span>已添加列</span>
          <ul class="dragsort needdragsort" data-group="1">
              <if condition="$field_sort==true">
                  <volist name="field_sort[1]" id="v">
                      <li class="getSort">
                          <em data="{$v}">{$v} [{$key}]</em>
                          <input type="hidden" name="field_sort[1][{$key}]" key="{$key}" value="{$v}"/>
                      </li>
                  </volist>
              <else/>
                  <volist name="data" id="v">
                      <li class="getSort">
                          <em data="{$v}">{$key} [{$v}]</em>
                          <input type="hidden" name="field_sort[1][{$key}]" key="{$key}" value="{$v}"/>
                      </li>
                  </volist>
              </if>
          </ul>
        </div>
        <div class="right">
          <span>隐藏列</span>
          <ul class="dragsort needdragsort" data-group="2">
              <volist name="field_sort[2]" id="v">
                  <li class="getSort">
                      <em data="{$v}">{$key} [{$v}]</em>
                      <input type="hidden" name="field_sort[2][{$key}]" key="{$key}" value="{$v}"/>
                  </li>
              </volist>
          </ul>
        </div>
    </div>
    
  	
	
    


    <div class="form-group formBtn">
    <div class="col-xs-3"></div>
    <div class="col-xs-9">
    <button class="btn btn-primary" type="submit" style="margin-left: 50px">提交</button>
        
    </div>
    </div>
	<input type="hidden" name="type" value="{$type}"/>
</form>

 <script type="text/javascript" src="__PUBLIC__/v2.3/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/v2.3/lib/layer/2.1/layer.js"></script> 
<script type="text/javascript" src="__PUBLIC__/v2.3/lib/My97DatePicker/WdatePicker.js"></script>  

<script type="text/javascript" src="__PUBLIC__/v2.3/js/H-ui.js"></script> 
<script type="text/javascript" src="__PUBLIC__/v2.3/js/H-ui.admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/v2.3/lib/Validform/5.3.2/Validform.min.js"></script> 
<script src="http://cdn.bootcss.com/jquery.form/3.51/jquery.form.min.js"></script>
<script type="text/javascript" src="/Tpl/Home/access/js/jquery.dragsort-0.5.1.min.js"></script>

<script>
        $(function(){
            $("#fields").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            beforeSubmit:function(curform){
            
                curform.ajaxSubmit({
                type:'POST',
                url:'{:U('fields/setCookie')}',
                success:function(data){
                  console.log(status);
                  if(data.status==true){
                      layer.msg('设置成功');
                      var index = parent.layer.getFrameIndex(window.name);
                      setTimeout(function(){
                           parent.layer.close(index);
                      },1500);
                      parent.location.reload();

                  }else{
                    layer.msg(data.sign);
                  }
                  }
                });
             return false; 
            }
          });
        });


        //全选
        $(document).on("click",".all",function(){
            if($('.all').is(':checked')){
                $('.box_col').find(':checkbox').attr("checked", false); 
                $('.col_check').each(function(){
                    $(this).find(':checkbox').prop("checked", 'true'); 
                 });
            }else{
                $('.box_col').find(':checkbox').attr("checked", false); 
            }
        });

        //拖曳插件初始化
        $(function(){
          $(".needdragsort").dragsort({
               dragSelector:'li',
               placeHolderTemplate: '<li class="draging-place">&nbsp;</li>',
               dragBetween:true,  //允许拖动到任意地方
               dragEnd:function(){
                 var self = $(this);
                   var key = self.find('input').attr('key');
                   alert(key);
                 self.find('input').attr('name', 'field_sort[' + self.closest('ul').data('group') + ']['+key+']');
               }
           });
        })
    </script>


</body>
</html>